#ifndef  __BSPM_DRIVER_H_
#define  __BSPM_DRIVER_H_

#include "BspSpi.h"
#include "DatStruct.h"
#include "BspM2_Driver.h"
#include "BspM1_Driver.h"

#define HOMING_SPEED	1000000	//4 r/m


#define FAST_HOME_SPEED (10000000 / 10 * handle->speed_home)
#define SLOW_HOME_SPEED (1000000 / 10 * handle->speed_home)

/*复位流程
 光电未触发 => 快速靠近光电 -> 快速离开光电 -> 慢速靠近光电
 光电触发   => 快速离开光电 -> 慢速靠近光电

*/
typedef enum{
	TYPE2_FAST_REACH = 0x21,
	TYPE2_FAST_LEAVE = 0x22,
	TYPE2_SLOW_REACH = 0x23,
	
	TYPE4_FAST_REACH = 0x41,
	TYPE4_FAST_LEAVE = 0x42,
	TYPE4_SLOW_REACH = 0x43,
}home_status_t;

void motor_poll(TypeDefTMC4361_RegStruct* handle);
void motor_home(TypeDefTMC4361_RegStruct* handle);
void motor_tarpos(TypeDefTMC4361_RegStruct* handle,int32_t tar);
void motor_current(TypeDefTMC4361_RegStruct* handle,int32_t data);
void my_curve(TypeDefTMC4361_RegStruct* handle,int32_t data);
void limit_switch(TypeDefTMC4361_RegStruct* handle);
#endif


